<template>
  <div>
    <div>
      <el-input
        v-model="input"
        style="width: 150px"
        placeholder="请输客户/产品"
        @change="findOrders(input)"
      ></el-input>
      <el-button type="primary" plain @click="ordersAdd">增加订单</el-button>
    </div>

    <el-table :data="ordersAllData" style="width: 100%">
      <el-table-column prop="startTime" label="下单时间"> </el-table-column>
      <el-table-column prop="state" label="订单状态">
        <template slot-scope="scope">
          <el-button type="success" disabled v-if="scope.row.state == 3"
            >支付成功</el-button
          >
          <el-button type="info" disabled v-if="scope.row.state != 3"
            >尚未支付</el-button
          >
        </template>
      </el-table-column>
      <el-table-column prop="termination" label="是否退保">
        <template slot-scope="scope">
          <el-button type="success" disabled v-if="scope.row.termination == 2"
            >已退保</el-button
          >
          <el-button type="info" disabled v-if="scope.row.termination == 1"
            >未退保</el-button
          >
        </template>
      </el-table-column>
      <el-table-column prop="endTime" label="下单时间"> </el-table-column>
      <el-table-column prop="salesId.name" label="销售员"> </el-table-column>
      <el-table-column prop="customersId.name" label="客户"> </el-table-column>
      <el-table-column prop="productsId.name" label="产品"> </el-table-column>
      <!-- <el-table-column prop="claimsId.name" label="理赔"> </el-table-column> -->
    </el-table>
  </div>
</template>

  <script>
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState } = createNamespacedHelpers("adminsOrders");
export default {
  mounted() {
    this.getOrdersList(localStorage.getItem("_id"));
  },
  data() {
    return {
      input: "",
    };
  },
  computed: {
    ...mapState(["ordersAllData"]),
  },
  methods: {
    ...mapActions(["getOrdersList",'getOrdersListId']),
    ordersAdd() {
      this.$router.push("/system/OrdersAdd");
    },
    findOrders(value){
     this.getOrdersListId({salesId:localStorage.getItem("_id") ,customersId:value,productsId:value})
    }
  },
};
</script>

<style>
</style>